{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## json文件批量添加内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "# 指定包含JSON文件的目录\n",
    "directory = ''\n",
    "\n",
    "# 遍历目录中的所有文件\n",
    "for filename in os.listdir(directory):\n",
    "    if filename.endswith('.json'):\n",
    "        file_path = os.path.join(directory, filename)\n",
    "        \n",
    "        # 读取JSON文件\n",
    "        with open(file_path, 'r', encoding='utf-8') as file:\n",
    "            data = json.load(file)\n",
    "        \n",
    "        # 添加新的键值对\n",
    "        data[\"DATA_PATH\"] = \"\"\n",
    "        \n",
    "        # 将修改后的数据写回文件\n",
    "        with open(file_path, 'w', encoding='utf-8') as file:\n",
    "            json.dump(data, file, indent=4)\n",
    "\n",
    "print(\"所有JSON文件已更新。\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
